#include "logindialog.h"
#include "ui_logindialog.h"

#include <QLineEdit>
#include <QMessageBox>

LoginDialog::LoginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginDialog)
{
    ui->setupUi(this);

//    setWindowFlags(Qt::FramelessWindowHint);
    setWindowTitle(tr("登录页面"));
//    setWindowTitle(QString::fromLocal8Bit("登录"));
    ui->ledPasswd->setEchoMode(QLineEdit::Password);
}

LoginDialog::~LoginDialog()
{
    delete ui;
}

void LoginDialog::on_btnLogin_clicked()
{
    QString userName = ui->ledUserName->text();
    QString passwd = ui->ledPasswd->text();
    if( "admin" != userName ||
        "admin" != passwd )
    {
        QMessageBox::warning(this,
            tr("waring"),
            tr("name or passward is wrong"),
            QMessageBox::Yes);
        return;
    }
    done(QDialog::Accepted);
//    setResult(QDialog::Accepted);
}

void LoginDialog::on_btnCancel_clicked()
{
    done(QDialog::Rejected);
//    setResult(QDialog::Rejected);
}
